<template>
  <el-row class="tac">
  <el-col :span="24">
    <el-menu
      default-active="3"
      class="el-menu-vertical"
      router
      unique-opened
      @open="handleOpen"
      @close="handleClose"
      background-color="#545c64"
      text-color="#fff"
      active-text-color="#ffd04b">

      <template v-for="item in menu">
        <el-submenu v-if="item.items.length" :index="item.key" :key="item.key">
          <template #title>
            <i v-bind:class="item.icon"></i>
            <span v-text="item.title"></span>
          </template>
          <el-menu-item-group class="over-hide" v-for="sub in item.items" :key="sub.key">
            <el-menu-item :index="sub.path">
              <template #title>
                <i v-bind:class="sub.icon"></i>
                <span v-text="sub.title"></span>
              </template>
            </el-menu-item>
          </el-menu-item-group>
        </el-submenu>
        <el-menu-item v-else :index="item.path" :key="item.key">
          <template #title>
            <i v-bind:class="item.icon"></i>
            <span v-text="item.title"></span>
          </template>
        </el-menu-item>
      </template>

    </el-menu>
  </el-col>
</el-row>
</template>

<style scoped>
  .over-hide{
    overflow: hidden;
  }
</style>

<script>
  import menu from '@/config/menu-config'

  export default {
    data () {
      return {
        menu: menu
      }
    },
    methods: {
      handleOpen (key, keyPath) {
        console.log(key, keyPath)
      },
      handleClose (key, keyPath) {
        console.log(key, keyPath)
      }
    }
  }
</script>